package br.edu.unifei.cct720.alieninvasion.entity.alien;

import br.edu.unifei.cct720.alieninvasion.entity.Entity;
import br.edu.unifei.cct720.alieninvasion.entity.ship.ShipShotEntity;
import br.edu.unifei.cct720.alieninvasion.main.gui.GameCanvas;
import br.edu.unifei.cct720.alieninvasion.utils.Constants;

/**
 * Class to represent an entity of an alien mothership
 * 
 * @author Felipe Knappe
 *
 */
public class AlienMotherShipEntity extends AlienShipEntity {

	/**
	 * Class constructor 
	 * Creates a new alien mother ship entity
	 * 
	 * @param g  The game in which this entity is being created
	 * @param x  The intial x-coordinate of this entity
	 * @param y  The intial y-coordinate of this entity
	 * @param st The parameter that tells if this entity moves only horizontally
	 * 
	 */
	public AlienMotherShipEntity(GameCanvas g, int x, int y, boolean st) {
		super(g, Constants.ALIEN_MOTHERSHIP, x, y, st);
	}

	/**
	 * Method responsible for notify this entity that it has collided 
	 * with another entity.
	 * 
	 * @param other The other collided entity
	 * 
	 */
	public void collidedWith(Entity other) {
		// if collision occurred with a shot entity, it dies
		if (other instanceof ShipShotEntity) {
			/*
			 *  it is needed to hit this entity some times
			 *  to get it down
			 */
			if(fired == this.game.getMotherShipHits()) {
 				game.removeAlienEntity(this);
				game.notifyGameFinished();
			} else {
				fired++;
			}
		}
	}
}
